/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mum.edu.cs.waa.assignment.model;

import com.sun.org.apache.bcel.internal.generic.AALOAD;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author teke
 */
public class Database {

    private String[] category= {"Music","Movie","Sport","TV"};
    private List<Account> accounts = new LinkedList<Account>();
    private List<Post> posts = new LinkedList<Post>();
    private static Database singletondb = null;
   

    private Database() {
     
    }

    public List<Account> getAccounts() {
        return accounts;
    }

    public void setAccounts(List<Account> accounts) {
        this.accounts = accounts;
    }

    public List<Post> getPosts() {
        return posts;
    }

    public void setPosts(List<Post> posts) {
        this.posts = posts;
    }    

    public static Database getDatabase() {
        if (singletondb == null) {
            singletondb = new Database();
        }
        return singletondb;
    }

    public Account GetAccount(String username, String password) {
        Account ret = null;
        for (Account acc : accounts) {
            if (acc.getName().equals(username)) {
                if (acc.getPassword().equals(password)) {
                    ret = acc;
                }
            }
        }
        return ret;
    }

}
